package console;

import java.io.StringWriter;
import java.io.PrintWriter;

/**
 * User: sachinh
 * Date: 25-Dec-2008
 * Time: 16:49:10
 */
public class Coord {
    public int x;
    public int y;

    public Coord(int[] pt) {
        x = pt[0];
        y = pt[1];
    }

    public Coord(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public String toString() {
        StringWriter writer = new StringWriter(10);
        PrintWriter w = new PrintWriter(writer);
        w.printf("%3d:%3d",x, y);
        return writer.getBuffer().toString();
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        final Coord coord = (Coord) o;

        if (x != coord.x) return false;
        if (y != coord.y) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = x;
        result = 29 * result + y;
        return result;
    }
}
